package com.jackchen.web.control;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.jws.soap.SOAPBinding.Use;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jackchen.common.filter.LoginFilter;
import com.jackchen.common.i18n.I18n;
import com.jackchen.po.Dball;
import com.jackchen.service.DballService;
import com.sun.net.httpserver.Filter;

@Controller
@RequestMapping(value="/exportset")
public class ExportControl {
	private static final Logger log = Logger.getLogger(ExportControl.class);
	
	@Autowired
	private I18n i18n;
	@Autowired
	private DballService dballService;
	
	@RequestMapping(value="/export")
	public String getPage(HttpServletRequest request,HttpServletResponse response){
		i18n.setLocalLanguage(request, response);
		return "log/Export";
	}
	
	@RequestMapping(value="/getExportValue")
	public @ResponseBody Map getExportValue(HttpServletRequest request,HttpServletResponse response){
		String userID = request.getSession().getAttribute(LoginFilter.SESSION_USER_NAME).toString();
		List<Dball> allDball = dballService.findAll("Dball");
		Map map = new HashMap();
		map.put("exportdata", allDball);
		return map;
	}
	
	@RequestMapping(value="/save")
	public @ResponseBody String save(Dball ball, HttpServletRequest request, HttpServletResponse response){
//		ExportSet export = new ExportSet();
//		export.setId(exportSetVO.getId());
//		export.setDate(exportSetVO.getDate());
//		export.setEveryDayOrWeekFlag(exportSetVO.getEveryDayOrWeekFlag());
//		export.setStartTime(exportSetVO.getStartTime());
//		String userID = request.getSession().getAttribute(LoginFilter.SESSION_USER_NAME).toString();
//		user.setUserId(userID);
//		export.setUser(user);
//		export.setLogType(exportSetVO.getLogType());
//		export.setWeekSign(exportSetVO.getWeekSign());
//		exportSetService.saveOrUpdate(export);
		return "success";
	}
}
